<template>
  <j-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :maskClosable="false"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel">
    <cms-article-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"/>
  </j-modal>
</template>

<script>

import CmsArticleForm from './CmsArticleForm'

export default {
  name: 'CmsArticleModal',
  components: {
    CmsArticleForm
  },
  data() {
    return {
      title: '',
      width: 800,
      visible: false,
      disableSubmit: false
    }
  },
  methods: {
    add() {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.realForm.add()
      })
    },
    edit(record) {
      this.visible = true
      this.$nextTick(() => {
        /* 模拟数据 */
        record = {
          'reports': 0,
          'source_dictText': '原创',
          'keywords': '',
          'color': '',
          'description': '测试外链测试外链测试外链测试外链测试外链测试外链测试外链测试外链测试外链',
          'source': '1',
          'status_dictText': '正常',
          'title': '测试外链',
          'updateBy': 'admin',
          'categoryId_dictText': '保商资讯',
          'orgCode': 'A01',
          'customContentView': null,
          'id': '1744890484419145730',
          'href': '',
          'weightDate': null,
          'image': '',
          'moduleType': '1',
          'wordCount': null,
          'weight': null,
          'updateTime': '2024-01-10 10:31:09',
          'categoryCode': 'A01A02A01',
          'viewConfig': null,
          'pvs': 21,
          'hitsPlus': 0,
          'hits': 0,
          'createBy': 'admin',
          'createTime': '2024-01-10 09:14:44',
          'hitsMinus': 0,
          'tenantId': null,
          'sysOrgCode': 'A01A01A01A01',
          'createById': 'e9ca23d68d884d4ebb19d07889727dae',
          'categoryId': '1519305041452711938',
          'remarks': '',
          'copyfrom': '',
          'status': '0',
          'moduleType_dictText': '文章'
        }
        this.$refs.realForm.edit(record)
      })
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      this.$refs.realForm.handleOk()
    },
    submitCallback() {
      this.$emit('ok')
      this.visible = false
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>

<style scoped>
</style>